package com.tencreat.service.mall.impl;

import java.time.LocalDateTime;
import java.util.List;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tencreat.common.core.domain.model.ReqIdParam;
import com.tencreat.common.core.domain.model.ReqIdsParam;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tencreat.domain.mall.MallGoodsCutOrder;
import com.tencreat.mapper.mall.MallGoodsCutOrderMapper;
import com.tencreat.service.mall.IMallGoodsCutOrderService;
import org.springframework.stereotype.Service;

/**
 * 砍价用户Service业务层处理
 *
 * @author wangkai
 * @date 2021-11-04
 */
@Service
public class MallGoodsCutOrderServiceImpl extends ServiceImpl<MallGoodsCutOrderMapper, MallGoodsCutOrder> implements IMallGoodsCutOrderService {


    /**
     * 查询砍价用户
     *
     * @param id 砍价用户ID
     * @return 砍价用户
     */
    @Override
    public MallGoodsCutOrder selectMallGoodsCutUserById(ReqIdParam id) {
        return baseMapper.selectById(id.getId());
    }

    /**
     * 查询砍价用户列表
     *
     * @param mallGoodsCutOrder 砍价用户
     * @return 砍价用户
     */
    @Override
    public List<MallGoodsCutOrder> selectMallGoodsCutUserList(MallGoodsCutOrder mallGoodsCutOrder) {
        return baseMapper.selectList(Wrappers.query(mallGoodsCutOrder));
    }

    /**
     * 新增砍价用户
     *
     * @param mallGoodsCutOrder 砍价用户
     * @return 结果
     */
    @Override
    public int insertMallGoodsCutUser(MallGoodsCutOrder mallGoodsCutOrder) {
        mallGoodsCutOrder.setCreateTime(LocalDateTime.now());
        return baseMapper.insert(mallGoodsCutOrder);
    }

    /**
     * 修改砍价用户
     *
     * @param mallGoodsCutOrder 砍价用户
     * @return 结果
     */
    @Override
    public int updateMallGoodsCutUser(MallGoodsCutOrder mallGoodsCutOrder) {
        mallGoodsCutOrder.setUpdateTime(LocalDateTime.now());
        return baseMapper.updateById(mallGoodsCutOrder);
    }

    /**
     * 批量删除砍价用户
     *
     * @param ids 需要删除的砍价用户ID
     * @return 结果
     */
    @Override
    public int deleteMallGoodsCutUserByIds(ReqIdsParam ids) {
        return baseMapper.deleteBatchIds(ids.getId());
    }

    /**
     * 删除砍价用户信息
     *
     * @param id 砍价用户ID
     * @return 结果
     */
    @Override
    public int deleteMallGoodsCutUserById(ReqIdParam id) {
        return baseMapper.deleteById(id.getId());
    }
}
